

#include "../include/qtwi/itemplates.hpp"


// ILabeledSlider

ILabeledSlider::ILabeledSlider(IWidget &parent, Ifactory &f, const char *cap,
			       int x, int y, int w, int h, int min, int max, int step, int page, bool grown_up = true) :
	
	// parameter grown_up means slider can take care of her action handling all alone
	
	ITemplate(parent, f)
{
	const int capt_w = 35, val_w = 36, lbl_height = 15;

	caption = ftory().makeLabel(&prent(), cap, x, y);
	caption->resize(capt_w, lbl_height);

	bar = ftory().makeScrollbar(&prent(), "", x + capt_w + 5, y,
				    min, max, step, page, IScrollbar::Horizontal);
		
	bar->resize(w - capt_w - val_w - 10, lbl_height);

	value = ftory().makeLabel(&prent(), _qtwi_to_string<int>(min).c_str(),
				  x + w - capt_w - val_w + 35, y);
		
	value->resize(val_w, lbl_height);

	// Fixme: This occasionally bugs, the workaround is to handle the callback in the enveloping class by means
	//        of double-registering this callback. Somehow really weird ...
	if(grown_up)
		ftory().getApp().registerAction(*bar, IAction::MOD, this);
		
	caption->show();
	value->show();
	bar->show();
}
